<!-- 巡检页面 -->
<template>
	<view>
		<dispatch ref="xunjian" :treeData="copyData"    @endEvent="getTreeListData" @searchChange="searchChange" @determine="determine"></dispatch>
	</view>
</template>

<script>
	import searchCom from "@/components/searchCom.vue"
	import dispatch from '../common/dispatch.vue'
	import mixins from '@/utils/mixins.js'
	import {
		getPlanLineSectionSiteStateTreeByLike, //树形列表
		inspectLogUpdateState, //更改状态
	} from '@/api/engineeringMaintenance/engineeringMaintenance.js'
	import {doGet} from "@/utils/offline/sqlite/index.js"
	// #ifdef APP-PLUS
	import { DB } from "@/utils/offline/sqlite/dbinit.js";
	// #endif
	export default {
		name: 'onSiteInspection',
		mixins:[mixins],
		components: {
			searchCom,
			dispatch
		},
		data() {
			return {
				treeData: [],
				copyData:[],
				startId:'',
			}
		},
		onShow() {
			this.$nextTick(() => {
				this.getTreeListData()
			})
		},
		methods: {
			// 获取树形数据
			getTreeListData(keyword = this.$refs.xunjian.keyword) {
			doGet(getPlanLineSectionSiteStateTreeByLike, {
						projectId: uni.getStorageSync('isOwner'),
						projectStates:["zj","zt"],
						type: 'inspect',
						keyword
					})
					.then(async res => {
					// #ifdef APP-PLUS
						console.log(await DB.select(`select count(*) from stations`), '--区间站点表--');	
					// #endif
						console.log(res,'-----树形数据resresres----')						
						if (res.status === 1 && res.success) {	
							this.treeData = res.result
							//复制一份做搜索用
							this.copyData = res.result
						}
					})


			},
			/**
			 * 输入框值变化的时候
			 * @param {String} val
			 */
			searchChange(val) {
				if(!val) {
					this.getTreeListData(val)
				}
			},
			determine(ev) {
				this.getTreeListData(ev)
			},

		}
	}
</script>

<style lang="scss" scoped>

</style>
